package com.zusmart.core.condition.extend;

import java.util.Map;

import com.zusmart.base.util.StringUtils;
import com.zusmart.core.bean.BeanDefinition;
import com.zusmart.core.condition.Condition;
import com.zusmart.core.condition.ConditionContext;
import com.zusmart.core.config.ConfigSourceManager;
import com.zusmart.core.plugin.PluginManager;

public class ConditionalUnHasPropertyRule extends ConditionalOnHasPropertyRule implements Condition {

	@Override
	public boolean matches(ConditionContext conditionContext, Map<String, BeanDefinition> beanDefinitions, BeanDefinition targetBeanDefinition, PluginManager pluginManager, ConfigSourceManager configSourceManager) {
		ConditionalUnHasProperty hasProperty = (ConditionalUnHasProperty) conditionContext.getExtendAnnotation();
		String prefix = hasProperty.prefix();
		String value = hasProperty.value();
		if (StringUtils.isBlank(value)) {
			return true;
		}
		return !this.doMatches(conditionContext, beanDefinitions, targetBeanDefinition, configSourceManager, pluginManager, prefix, value);
	}

}